<?php
class Model_job_seekers extends CI_Model {
	
	public function update_prefer_locations($prefer_locations,$job_seeker_id){
		$this->db->where('using_job_seeker_id',$job_seeker_id);
		$this->db->where_in('using_location_id',$prefer_locations);
		$this->db->update('job_preference_locations',array('is_prefered'=>'YES'));
		return true;
	}
	public function update_not_prefer_locations($prefer_locations,$job_seeker_id){
		$this->db->where('using_job_seeker_id',$job_seeker_id);
		$this->db->where_not_in('using_location_id',$prefer_locations);
		$this->db->update('job_preference_locations',array('is_prefered'=>'NO'));
		return true;
	}
	public function update_prefer_categories($prefer_categories,$job_seeker_id){
		$this->db->where('using_job_seeker_id',$job_seeker_id);
		$this->db->where_in('using_job_sub_category_id',$prefer_categories);
		$this->db->update('job_preference_categories',array('is_prefered'=>'YES'));
		return true;
	}
	public function update_not_prefer_categories($prefer_categories,$job_seeker_id){
		$this->db->where('using_job_seeker_id',$job_seeker_id);
		$this->db->where_not_in('using_job_sub_category_id',$prefer_categories);
		$this->db->update('job_preference_categories',array('is_prefered'=>'NO'));
		return true;	
	}
	public function get_manage_job_favorites(){
		$this->db->select('job_favorite_id,job_ads.title,date_available,job_ads_id,job_ads.title,job_keys,companies.name as company_name');
		$this->db->from('job_favorites');
		$this -> db -> join('job_seekers','job_seekers.job_seeker_id=job_favorites.using_job_seeker_id');
		$this -> db -> join('job_ads','job_ads.job_ads_id=job_favorites.using_job_ads_id');
		// $this -> db -> join('employers','employers.employer_id=job_ads.using_employer_id');
		$this -> db -> join('companies', 'companies.company_id=job_ads.using_company_id');
	    $this->db->where('job_favorites.using_job_seeker_id', $this->session->userdata('jobseeker_active_access'));
	    $this->db->order_by('job_favorite_id','DESC');
		return $this->db->get();
		
		
	}
}